package in.ac.dei.edrp.cms.controller.registration.prestagingcontroller;





import in.ac.dei.edrp.cms.dao.registration.prestagingdao.ReadyPreStagingDAO;
import in.ac.dei.edrp.cms.domain.registration.prestaging.ActivityMasterBean;


import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

@SuppressWarnings("deprecation")
public class ActivityMasterController extends SimpleFormController{

	private ReadyPreStagingDAO activityMasterService;
	
	public ActivityMasterController()	{
		setCommandClass(ActivityMasterBean.class);
		setCommandName("activityMasterBean");
	}
	
	public void setActivityMasterService(ReadyPreStagingDAO activityMasterService) {
		this.activityMasterService = activityMasterService;
	}
	
	 
	
	@SuppressWarnings("unchecked")
	@Override
	protected Map referenceData(HttpServletRequest request) throws Exception {
		//System.out.println("Coming here in Activity Master Controller");
		Map referenceData = new HashMap();
		//referenceData.put("processList", activityMasterService.getAllProcess());
		//referenceData.put("activityList", activityMasterService.getAllActivities("REG"));		
		return referenceData;
	}

	
	@Override
	protected ModelAndView onSubmit(Object command) throws Exception {
		System.out.println("inside model and view");
		ActivityMasterBean activityMasterBean = (ActivityMasterBean) command;
		System.out.println("inside model and view"+activityMasterBean.getEntityId());
		if(activityMasterBean.getEntityId().equalsIgnoreCase("00010001")){
			System.out.println("Running prestaging");
			activityMasterService.makePreStageReady(activityMasterBean);
		}
		return new ModelAndView("activityMaster","activityMasterBean",activityMasterBean);			
	}

}
